﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class UserControl_phong_tro_danh_sach : System.Web.UI.UserControl
{
    protected string strClassName = "UserControl_phong_tro_danh_sach";
    protected string strKieuPhong;
    protected string strKhuVuc;
    protected string strGia;
    protected string strDienTich;
    protected string strTrang;
    protected string strLinkPage = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            xGetParam();
        }
    }
    /// <summary>
    /// Lấy danh sách paramaster trên url
    /// Author: ThuanNH
    /// CreateDate: 01/08/2013
    /// </summary>
    private void xGetParam()
    {
        try
        {
            strKieuPhong = clsCommon.fncGetRoute(this.Page, "userControl");
            strKhuVuc = clsCommon.fncGetRoute(this.Page, "param1");
            strGia = clsCommon.fncGetRoute(this.Page, "param2");
            strDienTich = clsCommon.fncGetRoute(this.Page, "param3");
            strTrang = clsCommon.fncGetRoute(this.Page, "param4");
            //
            if (string.IsNullOrEmpty(strGia)) strGia = "0";
            if (string.IsNullOrEmpty(strDienTich)) strDienTich = "0";
            if (string.IsNullOrEmpty(strTrang)) strTrang = "1";
            //
            strLinkPage = "/" + strKieuPhong + "/" + strKhuVuc + "/" + strGia + "/" + strDienTich + "/" + (OsPortal.oStringHelper.fncCnvNullToInt(strTrang) + 1);
            //
            if (strKieuPhong == basConst.KP_TAT_CA) strKieuPhong = "";
            if (strKhuVuc == basConst.PT_TOAN_QUOC) strKhuVuc = "";
            //
            hd_KieuPhong.Value = strKieuPhong;
            hd_KhuVuc.Value = strKhuVuc;
            hd_Gia.Value = strGia;
            hd_DienTich.Value = strDienTich;
            hd_iCurrPage.Value = strTrang;

            xSeoOptimaze();
        }
        catch (Exception ex)
        {
            OsPortal.oFileHelper.WriteLogErr(strClassName, "xGetParam", ex.ToString());
        }
    }

    /// <summary>
    /// Set title, description, keyword
    /// Author: ThuanNH
    /// Create: 04/09/2013
    /// </summary>
    private void xSeoOptimaze()
    {
        string strTitle = "Cho Thuê Phòng Trọ, Nhà Trọ | nato.vn";
        string strKuVuc_Filter = clsCommon.fncGetRoute(this.Page, "param1").Replace('-', ' ');
        string strDescription = "Cho Thuê Phòng Trọ, Nhà Trọ | nato.vn";
        try
        {
            strTitle = "Cho thuê phòng trọ, nhà trọ " + strKuVuc_Filter;
            if (clsCommon.fncGetRoute(this.Page, "userControl") != basConst.KP_TAT_CA)
            {
                DataTable dtFilter = clsKieuPhongTro.fncGetChiTiet_by_TenKhongDau(strKieuPhong);
                strTitle = dtFilter.Rows[0]["kp_title"].ToString() + " " + strKuVuc_Filter;
                strDescription = dtFilter.Rows[0]["kp_mota"].ToString() + " " + strKuVuc_Filter;
            }
            //
            ltrTitle.Text = strTitle;
            //
            this.Page.Title = strTitle + " | " + strTitle + " | nato.vn";
            this.Page.MetaDescription = strDescription;
            this.Page.MetaKeywords = OsPortal.oStringHelper.fncGetAppSettings("KEYWORD");

        }
        catch (Exception ex)
        {
            OsPortal.oFileHelper.WriteLogErr(strClassName, "xSeoOptimaze", ex.ToString());
        }
    }
}